package com.madding.shared.hadoop.temperature;

import java.io.IOException;
import java.util.Iterator;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;

/**
 * 类MaxTemperatureReducer.java的实现描述：TODO 类实现描述 
 * @author madding.lip Aug 8, 2013 3:16:12 PM
 */
public class MaxTemperatureReducer extends MapReduceBase implements Reducer<Text, DoubleWritable, Text, DoubleWritable> {

    @Override
    public void reduce(Text key, Iterator<DoubleWritable> values, OutputCollector<Text, DoubleWritable> output, Reporter reporter) throws IOException {
       double maxValue = Double.MIN_VALUE;
       while(values.hasNext()) {
           maxValue = Math.max(maxValue, values.next().get());
       }
       output.collect(key, new DoubleWritable(maxValue));
    }
}
